import { post, get } from '@/utils/request'
import { mockLogin } from '@/mock/account.js'
import { buildUrl } from '@/utils/url'

/**
 * 发送短信验证码
*/
export function sendSmsVerifyCode (mobile) {
  return post('/system/auth/send-sms-code', Object.assign({
    operType: null,
    type: 'ESC',
    scene: 21,
      mobile: mobile
  }))
}


export function checkSmsVerifyCode (data) {
    return post('/system/sms/checkSmsCode', Object.assign({
        operType: null,
        type: 'ESC',
        code:data.code,
        username: data.username
    }))
}

/**
 * 发送重置密码验证码
*/
export function sendResetPwdVerifyCode (mobile) {
  return post('/system/user/sendSmsCode', Object.assign({
    operType: 'resetpwd',
    type: 'HTN',
    username: mobile
  }))
}

/**
 * 更新密码
*/
export function updateUserPassword (data) {
  return post(buildUrl('/system/user/profile/updatePwd', Object.assign({
    code: null,
    newPassword: null,
    username: null
  }, data)))
}

/**
 * 登录
*/
export function login (data) {
  return post(buildUrl('/auth/login', Object.assign({
    username: null,
    password: null,
    platform: 'WEAPP',
    type: 'HTN'
  }, data)))
}

/**
 * 获取登录用户
*/
export function getLoginUser () {
  return get('/system/user/getUserInfoById')
}

/**
 * 完善个人信息
 */
export function replenishAccount (data) {
	return post('/htnweapp/completePersonalInfo', Object.assign({
	  "id": null,
	  "companyName": null, // 所属公司名称
	  "knowFrom": null, // 从哪获知的混天凝
	  "position": null, // 职位
	  "realName": null // 真实姓名
	}, data))
}

/**
 * 更新登录用户信息
 */
export function updateLoginUser (data) {
	return post('/system/user/updateUserInfo', Object.assign({
		// avatar: null,
		// name: null,
		// ownCompanyId: null,
		// ownCompanyName: null
	}, data))
}

/**
 * 设置是否开启推送服务
 */
export function updateNeetPushService (data) {
	return post('/htnweapp/updateNeedService', Object.assign({
		flag: null // 0 关闭 1.开启
	}, data))
}

/**
 * 注销公司
 */
export function deleteHsmwUser (data) {
	return get('/htnweapp/deleteHsmwUserById',Object.assign({
	}, data))
}

/**
 * 用户手机号登录
 */
export function accountLogin(params) {
	return post(`/authorize/login?type=HTN&platform=WEAPP&code=${params.code}&username=${params.username}`)
}


export function smsLogin(params) {
    return post(`/system/auth/sms-login`,params)
}
